package kr.hkit.androidcomplete02.file;

import java.io.File;

import kr.hkit.androidcomplete02.R;
import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.EditText;

public class SDCard extends Activity {
	EditText mEdit;
	String mSdPath;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sdcard);
		
		mEdit = (EditText) findViewById(R.id.edittext);
		String ext = Environment.getExternalStorageState();
		if(ext.equals(Environment.MEDIA_MOUNTED)){
			mSdPath = Environment.getExternalStorageDirectory().getAbsolutePath();
		}else{
			mSdPath = Environment.MEDIA_UNMOUNTED;
		}
	}
	
	public void mOnClick(View v){
		switch(v.getId()){
		case R.id.test:
			String rootdir = Environment.getRootDirectory().getAbsolutePath();
			String datadir = Environment.getDataDirectory().getAbsolutePath();
			String cachedir = Environment.getDownloadCacheDirectory().getAbsolutePath();
			mEdit.setText(String.format("ext = %s\nroot=%s\ndata=&s\ncache=%s", 
					mSdPath, rootdir, datadir, cachedir));
			break;
		case R.id.save:
			File dir = new File(mSdPath + "/dir");
			dir.mkdir();
			File file = new File(mSdPath + "/dir/file.txt");
			
		}
	}
}
